package com.example.sangong.resp;

import com.example.sangong.entity.Attachment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("附件返回实体")
public class AttachmentUrlResp {
    @ApiModelProperty(value = "文件名称", required = true, example = "sg.png")
    private String fileName;
    @ApiModelProperty(value = "可以访问的地址", required = true, example = "http://nyk/filedata/sg.png")
    private String path;

    public static AttachmentUrlResp convert(Attachment attachment, String attachmentServer) {
        AttachmentUrlResp attachmentUrlResp = new AttachmentUrlResp();
        attachmentUrlResp.setFileName(attachment.getOrginalName());
        attachmentUrlResp.setPath(attachmentServer +"/"+ attachment.getNewName());
        return attachmentUrlResp;
    }
}
